package config

import "xy_api/pkg/config"

func init() {
	config.Add("database", config.StrMap{
		// 默认数据库
		"connection": config.Env("DB_CONNECTION", "mysql"),
		"mysql": map[string]interface{}{
			// 数据库连接信息
			"host":     config.Env("DB_HOST", "127.0.0.1"),
			"port":     config.Env("DB_PORT", "3306"),
			"database": config.Env("DB_DATABASE", ""),
			"username": config.Env("DB_USERNAME", "root"),
			"password": config.Env("DB_PASSWORD", "root"),
			"charset":  "utf8mb4",
			"loc":      config.Env("DB_LOC", "Asia/Shanghai"),
			// 连接池配置
			"max_open_connections": config.Env("DB_MAX_OPEN_CONNECTIONS", 25),  //设置打开数据库连接的最大数量
			"max_idle_connections": config.Env("DB_MAX_IDLE_CONNECTIONS", 100), // 设置最大空闲数
			"max_life_seconds":     config.Env("DB_MAX_LIFE_SECONDS", 5*60),    // 设置每个连接的超时时间
		},
		"sqlite": map[string]interface{}{
			"database": config.Env("DB_SQL_FILE", "database/database.db"),
		},
	})
}
